package de.lns.entities.effect;

import de.lns.tick.UpdateThread;
/**
 * 
 * @author Jascha
 *
 */
public abstract class TimedEffect extends Effect {

	protected int time;
	/**
	 * 
	 * @param entity The Entity this effect should be applied on.
	 * @param time The time this effect should last.
	 */
	public TimedEffect(Effectable entity, int time) {
		super(entity);
		this.time=time;
	}
	protected abstract void remove();
	@Override
	/**
	 * Removes the effect when the time is over.
	 */
	public void update(){
		if(UpdateThread.getDelta()>time){
			remove();
			this.entity.removeEffect(this);
		}
		else{
			time-=UpdateThread.getDelta();
		}
	}

}
